<template>
	<view>
		<view v-if="infos!=''">
			<u-cell-group>
				<u-cell title="核销码" :value="infos.redeem_code" />
				<u-cell title="奖品" :value="infos.prize_name" />
				<u-cell title="状态" :value="infos.status_text" />
				<u-cell title="核销时间" :value="infos.expire_time" v-if="infos.expire_time!=''" />
				<u-cell title="领取时间" :value="infos.receive_time" v-if="infos.receive_time!=''" />
				<!-- <u-cell title="有效期开始时间" :value="infos.start_time" /> -->
				<!-- <u-cell title="有效期结束时间" :value="infos.end_time" /> -->
			</u-cell-group>
			<view class="btns" @click="toCom()" v-if="infos.status==1">核销</view>
				<view class="btns" style="background: gainsboro;" v-if="infos.status==2">已核销</view>
			<view class="btns" style="background: gainsboro;" v-if="infos.status==3">已过期</view>
			<!-- <view style="padding: 20rpx;font-size: 30rpx;" v-if="infos.use_description!=''">
				<view style="margin-bottom: 10rpx;">使用规则</view>
				<rich-text :nodes="infos.use_description"></rich-text>
			</view> -->
		</view>
		<view class="loadMoreText" v-else>暂无数据</view>
	</view>
</template>

<script>
	import {
		managerMyListDetail,
		managerVerification
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				infos: ''

			};
		},
		onLoad(option) {
			this.redeem_code = option.no
			this.getDetail()
		},
		mounted() {},
		methods: {
			async getDetail() {
				const result = await managerMyListDetail({
					redeem_code: this.redeem_code
				})
				if (result.code == 1) {
					this.infos = result.data
				} else {
					uni.showToast({
						title: result.msg,
						icon: 'error'
					})
				}
			},
			toCom(){
				let that = this
				uni.showModal({
					title: '提示',
					content: '确定要核销吗？',
					success: function (res) {
						if (res.confirm) {
							that.toSubmit()
						} else if (res.cancel) {
						}
					}
				});

			},
			// 核销
			async toSubmit(){
				let that = this
				const result = await managerVerification({
					redeem_code: this.redeem_code
				})
				if(result.code==1){
					uni.showToast({
						title: result.msg,
					})
					setTimeout(()=>{
						that.getDetail()
					},500)
				}else{
					uni.showToast({
						title: result.msg,
						icon: 'error'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btns {
		font-size: 30rpx;
		color: white;
		font-weight: bold;
		background: #1397DC;
		border-radius: 10rpx;
		width: 432rpx;
		text-align: center;
		line-height: 80rpx;
		margin: 150rpx auto;
	}
</style>